home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagn_r.zip / RECORDS.SWG / 0003_MANYRECS.PAS.pas < prev    next >
Pascal/Delphi Source File  |  1993-05-28  |  2KB  |  51 lines

  1. {
  2. >Okay, I've got the need to load about 3000 Records, at 73 Bytes a piece,
  3. >into active memory.  It'd be preferred to have it as an Array of
  4. >Records, which is what I'm using now (only at 1000 Records though).
  5.  
  6. >When I do this I get Structure too Large.  Is there any way that I can
  7. >load all of these Records into memory, For sorting, editing, deleting
  8. >and adding new entries (which is easy With an Array).
  9.  
  10. }
  11. Const
  12.      MaxItems  = 3000 ;
  13.  
  14. Type TItem =
  15.      Record
  16.           { 73 Bytes Record }
  17.           Dum  : Array[1..73] of Byte ;
  18.      end ;
  19.      PItem = ^TItem ;
  20.  
  21.      TItemArray = Array[1..MaxItems] of PItem ;
  22.  
  23. Var  i    : Integer ;
  24.      Arr  : TItemArray ;
  25.  
  26. begin
  27.      For i:=1 to MaxItems Do New(Arr[i]) ;
  28.  
  29.      { Now, can use all those items in memory }
  30.  
  31.      For i:=1 to MaxItems Do Dispose(Arr[i]) ;
  32. end.
  33.  
  34. {
  35.  
  36. note that the set of data will occupy :
  37.  
  38. 3000*4 Bytes in DS            12000 Bytes
  39. 3000*80 Bytes in the heap    240000 Bytes
  40.                              ------
  41.                              252000 Bytes of memory...
  42.  
  43. The '80' in the second line is due to the fact that TP 6's heap manager
  44. allocates heap space by multiples of 8 Bytes, thus 73 Bytes result in
  45. 80 Bytes allocs. Reducing it to 72 Bytes would save 8*3000=24000 Bytes.
  46.  
  47. Anyway, this is not Real safe Programming, and you should prefer using a
  48. File, unleast you are Really sure that :
  49. - you won't have more than 3000 Records,
  50. - any machine your Program will run onto has enough memory.
  51. }